package com.jsyh.maidu.presenter;


import android.content.Context;

import com.jsyh.maidu.config.ConfigValue;
import com.jsyh.maidu.http.BaseDelegate;
import com.jsyh.maidu.http.OkHttpClientManager;
import com.jsyh.maidu.model.BaseModel;
import com.jsyh.maidu.utils.Utils;
import com.jsyh.maidu.views.CartGoodsView;
import com.squareup.okhttp.Request;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by admin on 2017/7/21.
 */

public class ChangeCardPresenter extends BasePresenter {

    CartGoodsView cartgoodsview;
    Context context;
    public ChangeCardPresenter (Context context,CartGoodsView cartgoodsview)
    {
        this.context=context;
        this.cartgoodsview=cartgoodsview;

    }

    public void LoadCardchange(String rec_id,String attr_id)
    {
        Map<String,String> params=new HashMap<>();
        params.put("key", ConfigValue.DATA_KEY);
        params.put("rec_id",rec_id);
        params.put("attr_id",attr_id);
        OkHttpClientManager.postAsyn(context, ConfigValue.APP_IP + "goods/edit_cart_attr", params, new BaseDelegate.ResultCallback<BaseModel>() {
            @Override
            public void onError(Request request, Object tag, Exception e) {
                Utils.showToast(context, "alterCartGoodsNumberError" + e);
            }

            @Override
            public void onResponse(BaseModel response, Object tag) {
                cartgoodsview.returnCardchange(response);

            }


        });

    }
}
